package nowcoder.duoduo2;

import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] nums1 = new int[num];
        int[] nums2 = new int[num];
        for(int i = 0; i < num; i++){
            nums1[i] = sc.nextInt();
        }
        for(int i = 0; i < num; i++){
            nums2[i] = sc.nextInt();
        }
        List<Integer> table = new ArrayList<>();
        Map<Integer, Integer> map = new HashMap<>(); // <牌，下标>
        int res1 = 0;
        int res2 = 0;
        int n1 = 0, n2 = 0;
        while (n1 < num || n2 < num){
            if(n1 < num){
                table.add(nums1[n1]);
                n1++;
                boolean flag = false;
                while (flag && n1 < num){
                    if(map.get(nums1[n1-1]) != null){
                        int start = map.get(nums1[n1-1]);
                        res1 += table.size()-start;
                        int n = table.size();
                        for(int j = start; j < n; j++){
                            map.remove(table.get(j));
                        }
                        if (n > start) {
                            table.subList(start, n).clear();
                        }
                        flag = false;
                        if(n1 < num){
                            n1++;
                            table.add(nums1[n1-1]);
                            map.put(nums1[n1-1], table.size()-1);
                            flag = true;
                        }
                    }else{
                        map.put(nums1[n1-1], table.size()-1);
                    }
                }

            }
            if(n2<num){
                table.add(nums2[n2]);
                n2++;
                boolean flag = true;
                while (flag && n2<num){
                    if(map.get(nums2[n2-1]) != null){
                        int start = map.get(nums2[n2-1]);
                        res2 += table.size()-start;
                        int n = table.size();
                        for(int j = start; j < n; j++){
                            map.remove(table.get(j));

                        }
                        if (n > start) {
                            table.subList(start, n).clear();
                        }
                        flag = false;
                        if(n2 < num){
                            n2++;
                            table.add(nums2[n2-1]);
                            map.put(nums2[n2-1], table.size()-1);

                            flag = true;
                        }

                    }else{
                        map.put(nums2[n2-1], table.size()-1);
                    }
                }

            }


        }


        for(Integer i : map.keySet()){
            if(i % 2 == 0){
                res2++;
            }else{
                res1++;
            }
        }
        System.out.println(res1 + " " + res2);
    }
    /**

     4
     1 2 3 6
     1 6 2 3

     11622336
     */

}
